package com.sanploy.manage.controller;

import com.sanploy.common.domain.dto.OrderSort;
import com.sanploy.common.vo.BaseException;
import com.sanploy.manage.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by zhu yingzhi on 2017/10/11.
 * @author yingzhi zhu
 * 后台订单请求路由类
 */
@RestController
@RequestMapping(value = "order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 分页获取所有订单 参数详见OrderSort
     * @param orderSort
     * @return
     */
    @GetMapping("")
    public Object getOrderSort(OrderSort orderSort){
        return orderService.findAllOrder(orderSort);
    }

    /**
     * 订单发货
     * @param order_id 订单号
     * @param transport_number 运单号 可为空 暂未实现此功能
     * @return
     */
    @GetMapping("/deliver")
    public Object deliverOrder(@RequestParam String order_id,@RequestParam(defaultValue = "") String[] transport_number) throws Exception {
        return orderService.deliverGoods(order_id,transport_number);
    }

    /**
     * 通过订单号查找订单
     *
     * @param order_id
     * @return
     * @throws BaseException
     */
    @GetMapping("{order_id}")
    public Object findOrderById(@PathVariable String order_id) throws BaseException {
        return orderService.findByOrderId(order_id);
    }



}
